Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.89 KB

[RTL8722CSM] [RTL8722DM] UART - Send and Receive.rst

File metadata and controls

58 lines (42 loc) · 1.89 KB

[RTL8722CSM] [RTL8722DM] UART - Send and Receive

Materials

  • AmebaD[AMB21 / AMB22] x 1
  • TTL USB to Serial module x 1

Steps

UART is a very versatile communication protocol and almost an essential part of a microcontroller. A TTL USB to Serial module is an IC that helps to translate UART signal to USB signal so that we can see uart log printed on our PC. This module is often found on many development boards, including ameba. However, the module on Ameba is reserved for LOG UART and Firmware uploading, that is why we need a separate module to communicate between ameba and PC.

There are currently 2 sets of UART available to MicroPython users and they are:

Unit tx RX
0 PA_21 PA_22
3 PA_26 PA_25
Here we are using unit 0 to demonstrate how uart works on ameba.
Connect TTL module to PA_21 and PA_22 as shown below,

image1

Then, copy and paste the following code line by line into REPL to see its effect.

from machine import UART
uart = UART(tx="PA_21", rx= "PA_22")
uart.init()
uart.write('hello')
uart.read(5) # read up to 5 bytes